<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="../common/NavigationLeft.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>二维码管理系统</title>
</head>
<body>
	<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
		<h2 class="page-header">已盘点资产</h1>
			<div class="row m-b-sm m-t-sm">
				<div class="col-md-4 f-r form-group form-inline">
					<a href="toPdAlreadyAsset"><button type="button"
							class="btn btn-default btn-sm">刷新</button></a>
					<s:if test="session.user.role == 0">
						<s:if test="pdStatus!=1 and ">
							<a href="editPdAsset.action?pdStatus=1"><button type="button"
																			class="btn btn-default btn-sm">开启盘点</button></a>
						</s:if>
						<s:if test="pdStatus==1">
							<a href="editPdAsset.action?pdStatus=2"><button type="button"
																			class="btn btn-default btn-sm">关闭盘点</button></a>
						</s:if>
					</s:if>

				</div>
				<div class="col-md-4 f-r">
					<div class="input-group">
						<input type="text" id="searchTemp" class="form-control" value="${temp }"
							name="temp" placeholder="请输入资产型号" style="height: 30px;">
						<span class="input-group-btn"><button
								class="btn btn-primary btn-sm" type="button" id="search_btn">搜索</button>
						</span>
					</div>
				</div>
				<div class="placeholder"></div>
		<table id="listTable" class="table" cellspacing="0">
			<%-- <caption>已经盘点的资产  共  ${pageNumAll} 个</caption> --%>
			<thead>
				<tr>
					<th>资产编号</th>
					<th>资产型号</th>
					<th>资产类别</th>
					<th>购买日期</th>
					<th>使用日期</th>
					<th>使用人</th>
					<th>资产状况</th>
				</tr>
			</thead>
			<tbody>
			</tbody>
		</table>
	</div>
</body>
<script type="text/javascript">
$(function(){
	/* if($("#pageCurr_hi").val()== "1"){
		$(".pull-right li:first").hide();
// 		alert("当前页"+$("#pageCurr_hi").val())
	}else{
		first =parseInt($("#pageCurr_hi").val());
		$(".pull-right li:first").attr("value",first-1);
	}
	
	if($("#pageCurr_hi").val()==$("#pageAll_hi").val()|| $("#pageAll_hi").val()=="3"){
// 		alert("当前页"+$("#pageCurr_hi").val())
// 		alert("当前页"+$("#pageAll_hi").val())
		$(".pull-right li:last").hide();
	}else{		
		last=parseInt($("#pageCurr_hi").val());
		$(".pull-right li:last").attr("value",last+1);
	}

	$(".pull-right li").click(function(){
		$("#pageCurr_hi").val($(this).attr("value"));
		$("#search_btn").click();
	});	 */
	var table = "";
	initTable();
	$("#search_btn").click(function(){
		initTable();
	});
	function initTable() {
		var temp = $("#searchTemp").val();
		$.fn.dataTable.ext.errMode = function(s,h,m){
            layer.alert('数据加载失败');
        }

		 table = $('#listTable').DataTable( {
			 "destroy" : true,
			"paging" : true,
			"lengthChange" : true,
			"searching" : false,
			"ordering" : false,
			"info" : true,
			"autoWidth" : false,
			"Filter" : false,
			responsive : true,
			"pagingType" : "full_numbers",
			"dom" : 'rtilp',
			"language" : {
				"url" : "/js/datatables/jquery.dataTables.zh"
			},
	        "processing": true,
	        "serverSide": true,
	        "ajax": {
	   	          type: 'POST',  
	   	          url: 'ajax_listPdAssetData.action',  
	   	       		data:{"temp":temp},
	   	          //contentType: 'application/json',  
	   	          timeout:60000  
	   	      },
             "drawCallback":function () {
                 
             },
	        "columns" : [
							{
								"data" : function(data) {
									if(data.equipIdentifier != null){
										return data.equipIdentifier;
									}else{
										return "--";
									}
								}
							},
							{
								"data" : function(data) {
									if(data.equipModel != null){
										return data.equipModel;
									}else{
										return "--";
									}
								}
							},
							{
								"data" : function(data) {
									if(data.equipGenre != null){
										return data.equipGenre;
									}else{
										return "--";
									}
								}
							},
							{
								"data" : function(data) {
									if(data.buyTime != null){
										var now = new Date(data.buyTime);
										var nowStr = now.format("yyyy-MM-dd");
										return nowStr;
									}else{
										return "--";
									}
								}
							},
							{
								"data" : function(data) {
									if(data.usedTime != null){
										var now = new Date(data.usedTime);
										var nowStr = now.format("yyyy-MM-dd");
										return nowStr;
									}else{
										return "--";
									}
								}
							},
							{
								"data" : function(data) {
									if(data.usePerson != null){
										return data.usePerson;
									}else{
										return "--";
									}
								}
							},
							{
								"data" : function(data) {
									if(data.status != null){
										return data.status;
									}else{
										return "--";
									}
								}
							}
					]
	    	} );
		return table;
	}
})

$(function(){
	var tip="${tip}";
	if(tip!=""){
		layer.msg(tip);
	}
});
Date.prototype.format = function(format){
	var o = {
	"M+" : this.getMonth()+1, //month
	"d+" : this.getDate(), //day
	"h+" : this.getHours(), //hour
	"m+" : this.getMinutes(), //minute
	"s+" : this.getSeconds(), //second
	"q+" : Math.floor((this.getMonth()+3)/3), //quarter
	"S" : this.getMilliseconds() //millisecond
	}

	if(/(y+)/.test(format)) {
	format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
	}

	for(var k in o) {
		if(new RegExp("("+ k +")").test(format)) {
			format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
		}
	}
	return format;
} 
</script>
</html>